import {combineReducers, createStore, Reducer, ReducersMapObject, Store} from 'redux';
import designIdsReducer, {DesignIdsState} from './designIdsReducer';
import designsReducer, {DesignsState} from './designsReducer';
import designNamesReducer, {DesignNamesState} from './designNamesReducer';
import activeDesignReducer, {ActiveDesignState} from './activeDesignReducer';
import selectedViewReducer, {SelectedViewState} from './selectedViewReducer';
import customWidgetsReducer, {CustomWidgetsState} from './customWidgetsReducer';
import scrollTopReducer, {ScrollTopState} from './scrollTopReducer';

export interface AppState extends Store<{}> {
  designIdsState: DesignIdsState;
  designsState: DesignsState;
  designNamesState: DesignNamesState;
  activeDesignState: ActiveDesignState;
  selectedViewState: SelectedViewState;
  customWidgetsState: CustomWidgetsState;
  scrollTopState: ScrollTopState;
}

const reducersMapObject: ReducersMapObject = {
  designIdsState: designIdsReducer,
  designsState: designsReducer,
  designNamesState: designNamesReducer,
  activeDesignState: activeDesignReducer,
  selectedViewState: selectedViewReducer,
  customWidgetsState: customWidgetsReducer,
  scrollTopState: scrollTopReducer
};
const reducers: Reducer<AppState> = combineReducers<AppState>(reducersMapObject);

const store: Store<AppState> = createStore(reducers);

export default store;
